Public Class frmBudgets
    Inherits System.Windows.Forms.Form
    Dim glbAdd As frmBudgetsAdd
    Friend WithEvents cmbYear As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents cmdPrint As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdRefresh As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdExit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdDelete As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdEdit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    Dim glbEdit As frmBudgetsEdit
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents dgProduct As System.Windows.Forms.DataGrid
    Friend WithEvents gLbudgetList1 As GLbudgetList
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.dgProduct = New System.Windows.Forms.DataGrid()
        Me.gLbudgetList1 = New GLbudgetList()
        Me.cmbYear = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        Me.cmdPrint = New DevComponents.DotNetBar.ButtonX()
        Me.cmdRefresh = New DevComponents.DotNetBar.ButtonX()
        Me.cmdExit = New DevComponents.DotNetBar.ButtonX()
        Me.cmdDelete = New DevComponents.DotNetBar.ButtonX()
        Me.cmdEdit = New DevComponents.DotNetBar.ButtonX()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        CType(Me.dgProduct, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupPanel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label1.Location = New System.Drawing.Point(9, 11)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(71, 18)
        Me.Label1.TabIndex = 279
        Me.Label1.Text = "Fiscal Year"
        '
        'dgProduct
        '
        Me.dgProduct.BackColor = System.Drawing.Color.AliceBlue
        Me.dgProduct.BackgroundColor = System.Drawing.Color.AliceBlue
        Me.dgProduct.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgProduct.CaptionVisible = False
        Me.dgProduct.DataMember = ""
        Me.dgProduct.HeaderBackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(128, Byte), Integer))
        Me.dgProduct.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgProduct.Location = New System.Drawing.Point(12, 88)
        Me.dgProduct.Name = "dgProduct"
        Me.dgProduct.ReadOnly = True
        Me.dgProduct.Size = New System.Drawing.Size(1051, 294)
        Me.dgProduct.TabIndex = 280
        '
        'cmbYear
        '
        Me.cmbYear.DisplayMember = "Text"
        Me.cmbYear.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cmbYear.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbYear.ItemHeight = 19
        Me.cmbYear.Location = New System.Drawing.Point(15, 57)
        Me.cmbYear.Name = "cmbYear"
        Me.cmbYear.Size = New System.Drawing.Size(213, 25)
        Me.cmbYear.TabIndex = 285
        '
        'cmdPrint
        '
        Me.cmdPrint.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdPrint.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdPrint.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdPrint.Location = New System.Drawing.Point(806, 397)
        Me.cmdPrint.Name = "cmdPrint"
        Me.cmdPrint.Size = New System.Drawing.Size(82, 27)
        Me.cmdPrint.TabIndex = 287
        Me.cmdPrint.Text = "Print"
        '
        'cmdRefresh
        '
        Me.cmdRefresh.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdRefresh.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdRefresh.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdRefresh.Location = New System.Drawing.Point(894, 397)
        Me.cmdRefresh.Name = "cmdRefresh"
        Me.cmdRefresh.Size = New System.Drawing.Size(82, 27)
        Me.cmdRefresh.TabIndex = 288
        Me.cmdRefresh.Text = "Refresh"
        '
        'cmdExit
        '
        Me.cmdExit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdExit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdExit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdExit.Location = New System.Drawing.Point(981, 397)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.Size = New System.Drawing.Size(82, 27)
        Me.cmdExit.TabIndex = 286
        Me.cmdExit.Text = "Exit"
        '
        'cmdDelete
        '
        Me.cmdDelete.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdDelete.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdDelete.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdDelete.Location = New System.Drawing.Point(718, 397)
        Me.cmdDelete.Name = "cmdDelete"
        Me.cmdDelete.Size = New System.Drawing.Size(82, 27)
        Me.cmdDelete.TabIndex = 287
        Me.cmdDelete.Text = "Delete"
        '
        'cmdEdit
        '
        Me.cmdEdit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdEdit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdEdit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdEdit.Location = New System.Drawing.Point(630, 397)
        Me.cmdEdit.Name = "cmdEdit"
        Me.cmdEdit.Size = New System.Drawing.Size(82, 27)
        Me.cmdEdit.TabIndex = 287
        Me.cmdEdit.Text = "Edit"
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.Label1)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(1075, 448)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 289
        Me.GroupPanel1.Text = "Budget"
        '
        'frmBudgets
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(1075, 448)
        Me.ControlBox = False
        Me.Controls.Add(Me.cmdEdit)
        Me.Controls.Add(Me.cmdDelete)
        Me.Controls.Add(Me.cmdPrint)
        Me.Controls.Add(Me.cmdRefresh)
        Me.Controls.Add(Me.cmdExit)
        Me.Controls.Add(Me.cmbYear)
        Me.Controls.Add(Me.dgProduct)
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ForeColor = System.Drawing.SystemColors.ControlLightLight
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Location = New System.Drawing.Point(40, 70)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmBudgets"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        CType(Me.dgProduct, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupPanel1.ResumeLayout(False)
        Me.GroupPanel1.PerformLayout()
        Me.ResumeLayout(False)

    End Sub

#End Region
    Private Sub Budgets_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim cYr As Integer = Now.Year
        cmbYear.Items.Clear()

        'commented Jackson on 29 july 2014--------------------------------------------------
        cmbYear.Items.Add((cYr - 1).ToString())
        cmbYear.Items.Add((cYr).ToString())
        cmbYear.Items.Add((cYr + 1).ToString())
        'cmbYear.Items.Add((cYr - 2).ToString() + "-" + (cYr - 1).ToString())
        'cmbYear.Items.Add((cYr - 1).ToString() + "-" + (cYr).ToString())
        'cmbYear.Items.Add((cYr).ToString() + "-" + (cYr + 1).ToString())


        'If Now.Month <= 5 Then
        '    cmbYear.SelectedItem = (cYr - 1).ToString() + "-" + (cYr).ToString()
        'Else
        '    cmbYear.SelectedItem = (cYr).ToString() + "-" + (cYr + 1).ToString()
        'End If
        'commented Jackson on 29 july 2014--------------------------------------------------

    End Sub
    Sub toPerformRefreshButtonClick()
        Dim GLdata As New GLdataLogic
        Dim ds As DataSet
        ds = GLdata.GetBudgetsByCompany(CompanyID, cmbYear.Text.Substring(0, 4))
        dgProduct.DataSource = ds.Tables(0)
        With dgProduct
            .TableStyles.Clear()
            .CaptionBackColor = System.Drawing.Color.SlateBlue
            .CaptionForeColor = System.Drawing.Color.LemonChiffon
            .AllowSorting = True
            .AlternatingBackColor = System.Drawing.Color.AliceBlue
            .ParentRowsBackColor = System.Drawing.Color.Lavender
            .ParentRowsForeColor = System.Drawing.Color.SlateBlue
            .HeaderBackColor = System.Drawing.Color.LemonChiffon
            .AllowNavigation = False
            .ParentRowsVisible = False
            .RowHeadersVisible = False
        End With
        Dim cm As CurrencyManager = BindingContext(dgProduct.DataSource, dgProduct.DataMember)
        Dim dv As DataView = cm.List
        dv.AllowNew = False
        dgformat(ds.Tables(0).Rows.Count)
        GLdata = Nothing
    End Sub
    Private Sub cmdRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRefresh.Click
        Me.Cursor = Cursors.WaitCursor
        toPerformRefreshButtonClick()
        Me.Cursor = Cursors.Default
    End Sub
    Private Sub dgformat(ByVal RowCount As Integer)
        Dim grdTableStyle As New DataGridTableStyle
        With grdTableStyle
            .AlternatingBackColor = Color.AliceBlue
            .HeaderFont = New Font("Calibri", 9.0!, FontStyle.Bold)
            .MappingName = "ACCOUNT"
            .PreferredColumnWidth = 160
            .HeaderBackColor = Color.LightSlateGray
            .HeaderForeColor = Color.LightCyan
            .PreferredRowHeight = 15
            .RowHeadersVisible = False
            .RowHeaderWidth = 0
        End With
        Dim cs1 As DataGridColumnStyle
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 0
        cs1.MappingName = "BUDID"
        cs1.HeaderText = "ID"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 70
        cs1.MappingName = "ACCOUNTNUMBER"
        cs1.HeaderText = "A/C NO"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 40
        cs1.MappingName = "ACCOUNTCENTER"
        cs1.HeaderText = "DPT"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 220
        cs1.MappingName = "ACCOUNTNAME"
        cs1.HeaderText = "DESCRIPTION"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "JANAMOUNT"
        cs1.HeaderText = "JAN"
        cs1.NullText = ""
        cs1.ReadOnly = True
        cs1.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "FEBAMOUNT"
        cs1.HeaderText = "FEB"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "MARAMOUNT"
        cs1.HeaderText = "MAR"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "APRAMOUNT"
        cs1.HeaderText = "APR"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "MAYAMOUNT"
        cs1.HeaderText = "MAY"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "JUNAMOUNT"
        cs1.HeaderText = "JUN"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "JULAMOUNT"
        cs1.HeaderText = "JUL"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "AUGAMOUNT"
        cs1.HeaderText = "AUG"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "SEPAMOUNT"
        cs1.HeaderText = "SEP"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "OCTAMOUNT"
        cs1.HeaderText = "OCT"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "NOVAMOUNT"
        cs1.HeaderText = "NOV"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "DECAMOUNT"
        cs1.HeaderText = "DEC"
        cs1.NullText = ""
        cs1.Alignment = HorizontalAlignment.Right
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 60
        cs1.MappingName = "TOTALAMOUNT"
        cs1.HeaderText = "TOTAL"
        cs1.Alignment = HorizontalAlignment.Right
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        dgProduct.TableStyles.Add(grdTableStyle)
    End Sub

    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Hide()
    End Sub


    Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 24) = True Then
            Dim CurrentRow As Integer = dgProduct.CurrentCell.RowNumber
            EditBudID = dgProduct.Item(CurrentRow, 0)
            glbEdit = New frmBudgetsEdit
            glbEdit.ShowDialog()
            toPerformRefreshButtonClick()
        Else
            MsgBox("Access Denied ", MsgBoxStyle.Critical, "Inventory Manager")
        End If
    End Sub

    Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
        Dim CurrentRow As Integer = dgProduct.CurrentCell.RowNumber
        dgProduct.Select(CurrentRow)
        Dim BudgetID As String = dgProduct.Item(CurrentRow, 0)
        Dim AccountCode As String = dgProduct.Item(CurrentRow, 1)
        Dim AccountDpt As String = dgProduct.Item(CurrentRow, 2)
        Dim AccountDesc As String = dgProduct.Item(CurrentRow, 3)
        If MsgBox("Are you sure to delete this budget line:" & AccountCode & ":" & AccountDpt & vbLf & AccountDesc, MsgBoxStyle.YesNo, "Inventory Manager") = MsgBoxResult.Yes Then
            Dim GLdata As New GLdataLogic
            Try
                GLdata.DeleteBudget(BudgetID)
                MsgBox("Budget for :" & AccountDesc & " deleted.", MsgBoxStyle.Information, "Inventory Manager")
                toPerformRefreshButtonClick()
            Catch ex As Exception
                MsgBox("Unable to satisfy your request." & vbLf & "Try again later.", MsgBoxStyle.Critical, "Inventory Manager")
            Finally
                GLdata = Nothing
            End Try
        End If
    End Sub

    Private Sub dgProduct_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgProduct.MouseUp
        Dim CurrentRow As Integer = dgProduct.CurrentCell.RowNumber
        dgProduct.Select(CurrentRow)
    End Sub

    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
        Dim ds As DataSet = New DataSet("SerpsRpt")
        Dim table As DataTable = New DataTable("SerpsRpt")
        table.Columns.Add("Str1")
        table.Columns.Add("Str2")
        table.Columns.Add("Str3")
        table.Columns.Add("Dec1")
        table.Columns.Add("Dec2")
        table.Columns.Add("Dec3")
        table.Columns.Add("Dec4")
        table.Columns.Add("Dec5")
        table.Columns.Add("Dec6")
        table.Columns.Add("Dec7")
        table.Columns.Add("Dec8")
        table.Columns.Add("Dec9")
        table.Columns.Add("Dec10")
        table.Columns.Add("Dec11")
        table.Columns.Add("Dec12")
        table.Columns.Add("Dec13")

        Dim mrow, drow As Integer
        Dim cm As CurrencyManager = BindingContext(dgProduct.DataSource, dgProduct.DataMember)
        Dim dv As DataView = cm.List
        dv.RowStateFilter = DataViewRowState.CurrentRows
        mrow = dv.Count
        'mrow = mrow - drow
        Dim ProdCode As String
        Dim ProdDesc As String
        Dim ProdQty As String

        Dim n As Integer
        For n = 0 To mrow - 1
            Dim nrow As DataRow = table.NewRow()
            nrow("Str1") = dgProduct.Item(n, 1)
            nrow("Str2") = dgProduct.Item(n, 2)
            nrow("Str3") = dgProduct.Item(n, 3)
            nrow("Dec1") = dgProduct.Item(n, 4)
            nrow("Dec2") = dgProduct.Item(n, 5)
            nrow("Dec3") = dgProduct.Item(n, 6)
            nrow("Dec4") = dgProduct.Item(n, 7)
            nrow("Dec5") = dgProduct.Item(n, 8)
            nrow("Dec6") = dgProduct.Item(n, 9)
            nrow("Dec7") = dgProduct.Item(n, 10)
            nrow("Dec8") = dgProduct.Item(n, 11)
            nrow("Dec9") = dgProduct.Item(n, 12)
            nrow("Dec10") = dgProduct.Item(n, 13)
            nrow("Dec11") = dgProduct.Item(n, 14)
            nrow("Dec12") = dgProduct.Item(n, 15)
            nrow("Dec13") = dgProduct.Item(n, 16)
            table.Rows.Add(nrow)
        Next
        ds.Tables.Add(table)

        gLbudgetList1.Load()
        gLbudgetList1.SetDataSource(ds)

        gLbudgetList1.SetParameterValue("CompanyName", CompanyTitle)
        gLbudgetList1.SetParameterValue("ReportTitle", "Financial Budget:" & cmbYear.Text)
        If PrntPrv Is Nothing Then
            PrntPrv = New PrintPreviewForm
            PrntPrv.CrRptView.ReportSource = gLbudgetList1
            PrntPrv.ShowDialog()
        End If
        gLbudgetList1.Close()
        'glbudgetlist1.PrintOptions.PrinterName = InvoicePrinter
        'Try
        '    glbudgetlist1.PrintToPrinter(1, True, 0, 0)
        'Catch ex As Exception
        '    MsgBox(ex.ToString)
        'End Try
    End Sub
End Class
